package com.syx.order.Service;

import com.syx.order.Api.ProductApi;
import com.syx.order.Dao.OrderMapper;
import com.syx.order.Model.OrderInfo;

import com.syx.product.Model.ProductInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class OrderService {
    @Resource
    private OrderMapper orderMapper;

    @Resource
    RestTemplate restTemplate;

    @Resource
    ProductApi productApi;



    public OrderInfo selectOrderById(Integer id){
        OrderInfo orderInfo = orderMapper.selectOrderById(id);

        /*String url="http://product-service/product/"+orderInfo.getProductId();
        ProductInfo productInfo = restTemplate.getForObject(url, ProductInfo.class);*/
        ProductInfo productInfo=productApi.getProductInfo(orderInfo.getProductId());
        orderInfo.setProductInfo(productInfo);

        return orderInfo;



    }
}
